
#pragma comment(lib, "ws2_32.lib")
#include "C_UDPServer.h"



static void usage()
{
	fprintf(stderr, "Usage : UDPFileServer[OPTIONS]\n\n");
	fprintf(stderr, "Input options:\n");
	fprintf(stderr, " -i        string : input filename \n");
	fprintf(stderr, " -help            : prints this help message\n");
	fprintf(stderr, " -port      int      : the server port\n");
	fprintf(stderr, " -loglevel  int      : the log level \n");
	fprintf(stderr, "\n");
	fprintf(stderr, "\n");
}


int main(int argc,char *argv[])
{
	int i;
	int m_iListenPort = -1;
	char* m_pInputFile = NULL;
	int iLogFlag = 0;

	for (i = 1; i < argc; i++) 
	{

		if (strcmp("-port", argv[i]) == 0 && i < argc - 1)
		{
			i++;
			m_iListenPort = atoi(argv[i]);
		} 
		else if (strcmp("-i", argv[i]) == 0 && i < argc - 1) 
		{
			i++;
			m_pInputFile = argv[i];
        } 
		else if (strcmp("-loglevel", argv[i]) == 0 && i < argc - 1) 
		{
			i++;
			iLogFlag = atoi(argv[i]);
		} 
	
		else if (strcmp("-help", argv[i])) 
		{
			usage();
			return (0);
		} 
		else
		{
			usage();
			exit(-1);
		}

	}

	
	C_MServer m_UDPFileServer;
	
	if(m_UDPFileServer.init("5000","4501","test.dat",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0)
	{
	printf("The server can not init");
	return 0;
	}

	if(m_UDPFileServer.start()<0)
	{
	printf("The server can not start");
	return 0;
	}
	
	
	getchar();
	m_UDPFileServer.stop();

	return 1;
}